<template>
  <div class="app-container">
    <basics-form
      ref="basicsForm"
      :actionLoading="loading"
      @actionBtnsClick="actionBtnsClick"
      @submit="search"
    />
    <el-table
      v-loading="tableLoading"
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      stripe
      style="width: 100%"
    >
      <el-table-column prop="x" label="医院名称" width="180"> </el-table-column>
      <el-table-column prop="a" label="行政区域"> </el-table-column>
      <el-table-column prop="b" label="详细地址"> </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog
      title="选择医院"
      :visible.sync="openView"
      width="1200px"
      append-to-body
    >
      <organi isComponent/>
    </el-dialog>
  </div>
</template>

<script>
import BasicsForm from "@/components/BasicsForm";
import Organi from "../organi";
export default {
  name: "organi-index",
  components: { BasicsForm,Organi },
  data() {
    return {
      loading: false,
      tableLoading: false,
      openView: false, //选择医院弹出
      total: 25,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
      },
      tableData: [],
      tableData2: [
        {
          x: "x",
          a: "王小虎",
          b: "234",
          c: "3.2",
          d: 10,
        },
        {
          x: "x",
          a: "王小虎",
          b: "234",
          c: "3.2",
          d: 10,
        },
        {
          x: "x",
          a: "王小虎",
          b: "234",
          c: "3.2",
          d: 10,
        },
        {
          x: "x",
          a: "王小虎",
          b: "234",
          c: "3.2",
          d: 10,
        },
        {
          x: "x",
          a: "王小虎",
          b: "234",
          c: "3.2",
          d: 10,
        },
      ],
    };
  },
  created() {
   
  },
  methods: {
    init(){
      this.initRules();
      this.getList();
    },
    //搜索
    search(param) {
      if (!param) {
        return;
      }
      for (let key in param) {
        this.queryParams[key] = param[key];
      }
      this.getList();
    },
    getList() {
      this.loading = true;
      this.tableLoading = true;
      this.tableData = [];
      setTimeout(() => {
        this.tableData = this.tableData2;
        this.loading = false;
        this.tableLoading = false;
      }, 1000);
      console.log(this.queryParams, "---");
    },
    initRules() {
      let rules = [
        {
          title: "医院",
          key: "a",
          skip: true,
        },
        {
          type: "actionBtns",
          selectList: [{ name: "搜索", value: "primary" },
            { name: "新增", value: "success" },
          ],
          ruleWidth:'auto'

        },
      ];
      this.$refs.basicsForm.initForm(rules);
    },
      actionBtnsClick(index) {
      if (index == 1) {
        this.openView = true;
      } else {
        this.$refs.basicsForm.formValid();
      }
    },
  },
};
</script>
